<template>
    <div>
        <van-nav-bar title="商城" />
        <van-search v-model="value" placeholder="请输入搜索关键词" @search="onSearch"/>
        
        <van-tabs v-model:active="active">
            <van-tab title="标签 1">内容 1</van-tab>
            <van-tab title="标签 2">内容 2</van-tab>
            <van-tab title="标签 3">内容 3</van-tab>
            <van-tab title="标签 4">内容 4</van-tab>
        </van-tabs>
        <van-swipe :autoplay="3000" lazy-render style="width: 100%;height: 200px;">
            <van-swipe-item v-for="image in images" :key="image">
                <img :src="image" style="width: 100%;height: 200px; " />
            </van-swipe-item>
        </van-swipe>
        <!-- 导航 -->
        <van-grid :column-num="4">
            <van-grid-item v-for="item in catitems" :icon="item.image_src" :text="item.name" />
        </van-grid>
        <!-- 楼层数据 -->
        <div v-for="item in floordata">
            <img :src="item.floor_title.image_src" style="width: 120px;height: 120px;" alt="">
            <div v-for="items in item.product_list">
                <img :src="items.image_src" alt="">
            </div>
        </div>
        
    </div>
</template>

<script setup>
import { ref, watch } from 'vue';
import router from '@/router';
import { floordataApi } from '@/api/api';
import { catitemsApi } from '@/api/api';
let catitems = ref([])
let floordata = ref('')
let value=ref('')

floordataApi().then(res => {
    console.log('楼层', res.data.message);
    floordata.value = res.data.message
})
catitemsApi().then(res => {
    console.log('导航', res);
    catitems.value=res.data.message
})
const onSearch = () => {
    router.push('/search')
}
const images = [
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-1.jpeg',
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-2.jpeg',
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-3.jpeg',
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-4.jpeg',
];

</script>

<style lang="scss" scoped></style>